package dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jaay.DeepEntity;
import com.jaay.pojo.Product;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.math.BigDecimal;
import java.util.Optional;

@Data
public class ProductDto implements DeepEntity<Product> {

    /**
     * 订单编号
     */
    private String orderNo;
    /**
     * 商品名称
     */
    private String productName;
    /**
     * 商品详情
     */
    private String description;
    /**
     * 数量
     */
    private Integer quantity;
    /**
     * 商品价格
     */
    @JsonFormat(pattern = "####.##")
    private BigDecimal productPrice;

    @Override
    public Optional<Product> copy() {

        Product product = new Product();
        BeanUtils.copyProperties(this,product);
        return Optional.of(product);
    }
}
